package com.ethanzzh.security.ethanzzhcore.validate.code;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.awt.image.BufferedImage;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ValidateCode implements Serializable {

    private static final long serialVersionUID = -6913743595818708753L;
    private String code;

    private LocalDateTime expireTime;



    public ValidateCode(String code, int expireIn) {
        this.code = code;
        //当前时间加上60秒作为过期时间
        this.expireTime = LocalDateTime.now().plusSeconds(expireIn);
    }

    public boolean isExpried() {
        return LocalDateTime.now().isAfter(expireTime);
    }
}
